package cn.springmvc.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.springmvc.common.datasource.DataSourceEnum;
import cn.springmvc.common.datasource.DynamicDataSourceHolder;
import cn.springmvc.entity.User;
import cn.springmvc.entity.UserRole;
import cn.springmvc.repository.UserRoleRepository;

/**
 * @author Vincent.wang
 *
 */
@Repository
public class UserRoleDaoService {

    @Autowired
    protected UserRoleRepository userRoleRepository;

    public void add(UserRole userRole) {
        DynamicDataSourceHolder.setDataSourceKey(DataSourceEnum.MASTER.getKey());
        userRoleRepository.add(userRole);
    }

    public void updatePassword(User u) {
        DynamicDataSourceHolder.setDataSourceKey(DataSourceEnum.MASTER.getKey());
        userRoleRepository.updatePassword(u);
    }

}
